<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>请假记录</title>
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/resources/script/jquery-3.1.1.js"></script>
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/resources/script/layer-v3.0.1/layer/layer.js"></script>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$('.delete')
								.click(
										function() {
											var lid = $(this).parent().parent()
													.attr('id');
											layer
													.confirm(
															'是否要删除这条记录？',
															{
																btn : [ '确定',
																		'取消' ]
															},
															function() {
																//layer.msg('您点击了确定' + lid);
																window.location.href = "${ pageContext.request.contextPath}/usermanager/deleteleave?lId="+lid;
															}, function() {
																//layer.msg('您点击了取消');
															});
										});
						$('#new').click(function() {
							layer.open({
								title : '请假申请',
								type : 2,
								area : [ '525px',
										'385px' ],
								content : '${ pageContext.request.contextPath }/usermanager/newleave',
								cancel: function(index){ 
									location.reload([true]);
									}
							});
						});
					});
</script>
<link type="text/css" rel="stylesheet"
	href="${ pageContext.request.contextPath }/resources/csses/not_leave_.css">
<style type="text/css">
</style>
</head>
<body>
	<div id="containertitle">
		请假记录
		<div style="float: right;">
			<a id="new" style="text-align: right;" href="#">请假申请</a>
		</div>
	</div>
	<table id="leavetable" class="manager">
		<thead id="leavethead" class="managerthead">
			<tr>
				<td></td>
				<th>姓名</th>
				<th>请假类型</th>
				<th>开始时间</th>
				<th>结束时间</th>
				<th>请假原因</th>
				<td></td>
			</tr>
		</thead>

		<tbody>

			<c:forEach items="${ leaves }" var="leave" varStatus="statu">
				<tr id="${ leave.id }">
					<td class="cell">${ statu.index + 1 }</td>
					<td class="cell">${ leave.user.getRealName() }</td>
					<td class="cell">${ leave.type }</td>
					<td class="cell">${ leave.fromTimeStr }</td>
					<td class="cell">${ leave.toTimeStr }</td>
					<td class="cell">${ leave.reason }</td>
					<td class="cell"><img class="delete" alt="Delete"
						src="${ pageContext.request.contextPath }/resources/images/Delete.png"
						width="20px;" height="20px;"></td>
				</tr>
			</c:forEach>

			<tr>
				<td style="text-align: center; font-size: 15px;" colspan="7"><a style="text-decoration: none; font-size: 12px;"
					href="${ pageContext.request.contextPath }/${ roler }/leave?current=${ currentPage > 1 ? currentPage - 1 : 1}"><<上一页&nbsp;&nbsp;</a>
					<c:choose>
						<c:when test="${ pagecount <= 5 }">
							<c:forEach begin="1" end="${ pagecount }" var="index" step="1">
								<c:choose>
									<c:when test="${ index == currentPage }">
										<a style="color: red;"><c:out value="${ index }" /> </a>
									</c:when>
									<c:otherwise>
										<a style="text-decoration: none;"
											href="${ pageContext.request.contextPath }/${ roler }/leave?current=${ index}"><c:out
												value="${ index }" /> </a>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</c:when>
						<c:when test="${ currentPage > pagecount - 2 }">
							<c:forEach begin="${ pagecount - 4 }" end="${ pagecount }"
								step="1" var="index">
								<c:choose>
									<c:when test="${ index == currentPage }">
										<a style="color: red;"><c:out value="${ index }" /> </a>
									</c:when>
									<c:otherwise>
										<a style="text-decoration: none;"
											href="${ pageContext.request.contextPath }/${ roler }/leave?current=${ index}"><c:out
												value="${ index }" /> </a>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<c:choose>
								<c:when test="${ currentPage > 3 }">
									<c:forEach begin="${ currentPage - 2 }"
										end="${ currentPage + 2 > pagecount ? pagecount : currentPage + 2}"
										step="1" var="index">
										<c:choose>
											<c:when test="${ index == currentPage }">
												<a style="color: red;"><c:out value="${ index }" /> </a>
											</c:when>
											<c:otherwise>
												<a style="text-decoration: none;"
													href="${ pageContext.request.contextPath }/${ roler }/leave?current=${ index}"><c:out
														value="${ index }" /> </a>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</c:when>
								<c:otherwise>
									<c:forEach begin="1" end="${ pagecount < 5 ? pagecount : 5 }"
										var="index" step="1">
										<c:choose>
											<c:when test="${ index == currentPage }">
												<a style="color: red;"><c:out value="${ index }" /> </a>
											</c:when>
											<c:otherwise>
												<a style="text-decoration: none;"
													href="${ pageContext.request.contextPath }/${ roler }/leave?current=${ index}"><c:out
														value="${ index }" /> </a>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</c:otherwise>
					</c:choose> <a style="text-decoration: none; font-size: 12px;"
					href="${ pageContext.request.contextPath }/${ roler }/leave?current=${ currentPage < pagecount ? currentPage + 1 : pagecount}">&nbsp;&nbsp;下一页>></a>
				</td>
			</tr>
		</tbody>
	</table>
</body>
</html>